<!DOCTYPE html>
<html lang="en">
<head>
<title>Using with MTConnect</title>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/custom.css">
</head>

<body>

<div class="container">
<nav class="navbar">
<a class="btn btn-info btn-xs navbar-btn pull-right" href="index.html">Back to Docs</a>
</nav>

<H1>Using with MTConnect</H1>

<p>To use the NC.js package for monitoring an MTConnect connection,
follow the normal <a href="build.html">build instructions</a> but
build and start the server using the separate "-MT" configurations as
below.  This starts the server with the MTConnect support.

<pre>
> npm run make-MT
> npm run start-MT
> npm run start-MT -- -f "path_to_file.stpnc"
</pre>

<P>Pressing Play on the client will start MTConnect monitoring and
engage the simulator.
<p>The MTConnect monitoring code is defined in <a href="https://github.com/steptools/NC.js/blob/master/src/server/api/v3/MTstate.js">MTstate.js</a></p>


<H2>Selecting the MTConnect Source</H2>

<p>In the <code>config.js</code> file, you will find a "machineList"
property that is an array of name/address pairs.  Populate this list
with the addresses of your MTConnect servers.

<PRE>
"machineList" : [
   { name: 'Okuma', address: 'okuma.steptools.com:5000' }
]
</PRE>

<p>GET on the <code>/v3/nc/state/machines</code> endpoint will return
this array.

<p>GET on the <code>/v3/nc/state/machine</code> endpoint will return
the index within the array of the MTConnect server that is being
monitored.  By default the initial element (index '0') is monitored.

<p>GET on the <code>/v3/nc/state/machine/{idx}</code> endpoint will
change the server to monitor the MTConnect server at that position in
the array.


<H2>Getting the MTConnect Status</H2>

<p>GET on the <code>/v3/nc/state/mtc</code> endpoint will return an
object with the latest information from the server.  This object
contains the current G-Code block number, speed and feed, and whether
the connection is live.

<PRE>
{
  "feedrateUnits":"Millimeters/Second",
  "live":true,
  "spindleSpeed":"0",
  "feedrate":"0",
  "currentGcodeNumber":"2097",
  "baseFeed":-1,
  "optimizedFeed":-1
}
</PRE>

</div>

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
